/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package test;

import java.util.Collection;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

/**
 *
 * @author François
 */
@Stateless
public class HelloWorld implements HelloWorldLocal {

    @PersistenceContext
    private EntityManager em;

    @Override
    public String getMessage() {
        System.out.println("Hello World qui va s'afficher dans la console du serveur, pour trace");
        return "Hello World Vive les patates !";
    }

    @Override
    public void printAllManufacturers() {
        Query query = em.createNamedQuery("Manufacturer.findAll");
        Collection< Manufacturer> result = query.getResultList();

        for (Manufacturer cust : result) {
            System.out.println(cust.getName());
        }
    }

    @Override
    public Collection getAllManufacturers() {
        Query query = em.createNamedQuery("Manufacturer.findAll");
        Collection< Manufacturer> result = query.getResultList();

        return result;
    }
}
